home *** CD-ROM | disk | FTP | other *** search
- {******************************************************************
- * Unit : TomApi95.pas *
- * Desc. : API Tools f. Delphi II / Win 95 *
- * Author : Thomas Hⁿhn *
- * Created : 09.10.1997 *
- * Target : Delphi II (maybe also III not testet yet *
- * Copyright : ⌐1997 Thomas Hⁿhn *
- * E-Mail Adress of the Author is thomashueh@aol.com *
- * or tomh@supernews.com *
- *******************************************************************
-
- Feel free to use this unit in you own programms. But you are not
- allowed to sell it as your own work!! If you share this unit then
- share it in one part!!! The author is not reponsible for any damage
- on your system - use it or let it!! Don't worry it's not a virus..LOL
- For Comments feel free to send me a mail. If you made usefull changes
- please send them to me. The Source life!!
- And don't forget DELPHI RULES!
-
- Tom.
-
-
- ...........................................................................
- History:
- ░░░░░░░
- 09.10.1997: started with FileFunctions
- 09.10.1997: to early to sleep also added ExecFile 11:59 p.m.
- ...........................................................................
- }
-
-
- unit TomApi95;
-
- interface
- uses Windows,Classes,SHELLAPI;
-
- //------------File Copy/Move/Delete Functions only Windows 95 not NT!! ---------
- // aHandle:Handle of Window (your Form only type in Handle)
- // ASource:TString filled with Files
- // ADest:DestinationDirectory
- // Returns false if User aborted
- // Note: aHandle is needed to allocate the API-PROGRESSDIALOG
- // Note2: Delete deletes really it don't move to the Thrash-Bin!!
- // Example: ShFileCopy(Handle,DirecoryListbox1.Items,'C:\TMP')
- Function ShFileCopy(aHandle:HWND;ASource:TStrings;ADest:String):boolean;
- Function ShFileMove(aHandle:HWND;ASource:TStrings;ADest:String):boolean;
- Function ShFileDelete(aHandle:HWND;ASource:TStrings):boolean;
-
-
- //------------------File Exec Function Windows 95 and NT!! -----------------
- // aCmdLine : File to Exec
- // AHide : Hide Window
- // aWait : Wait for End of Application
- // Returns false if execute fails
- function fileExec(const aCmdLine: String; aHide, aWait: Boolean): Boolean;
-
-
- //----------------------------- IMPLEMANTATION-------------------------------
- implementation
- var
- shellinfo : TSHFILEOPSTRUCT ;
-
- //------------File Copy Function only Windows 95 not NT!! ---------
- Function ShFileCopy(aHandle:HWND;ASource:TStrings;ADest:String):boolean;
- var i:integer;
- Files:string;
- begin
-
- Files:='';
- for i:=0 to ASource.count-1 do
- Files:=Files+ASource[i]+#0;
- Files:=Files+#0;
- With shellInfo do
- begin
- wnd:=aHandle;
- wfunc:=FO_COPY;
- pFrom:=PChar(files);
- pTo:=PChar(ADest);
- Result:= ShellInfo.fAnyOperationsAborted ;
- end;
- SHFileOperation(shellInfo);
- end;
-
- //------------File Move Function only Windows 95 not NT!! ---------
- Function ShFileMove(aHandle:HWND;ASource:TStrings;ADest:String):boolean;
- var i:integer;
- Files:string;
- begin
-
- Files:='';
- for i:=0 to ASource.count-1 do
- Files:=Files+ASource[i]+#0;
- Files:=Files+#0;
- With shellInfo do
- begin
- wnd:=aHandle;
- wfunc:=FO_MOVE;
- pFrom:=PChar(files);
- pTo:=PChar(ADest);
- Result:= not ShellInfo.fAnyOperationsAborted ;
- end;
- SHFileOperation(shellInfo);
- end;
-
- //------------File Delete Function only Windows 95 not NT!! ---------
- Function ShFileDelete(aHandle:HWND;ASource:TStrings):boolean;
- var i:integer;
- Files:string;
- begin
- Files:='';
- for i:=0 to ASource.count-1 do
- Files:=Files+ASource[i]+#0;
- Files:=Files+#0;
- With shellInfo do
- begin
- wnd:=aHandle;
- wfunc:=FO_DELETE;
- pFrom:=PChar(files);
- pTo:=nil;
- Result:= not ShellInfo.fAnyOperationsAborted ;
- end;
- SHFileOperation(shellInfo);
- end;
-
- //------------------File Exec Function Windows 95 and NT!! -----------------
- function fileExec(const aCmdLine: String; aHide, aWait: Boolean): Boolean;
- var
- StartupInfo : TStartupInfo;
- ProcessInfo : TProcessInformation;
- begin
- FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
- with StartupInfo do
- begin
- cb:= SizeOf(TStartupInfo);
- dwFlags:= STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
- if aHide then wShowWindow:= SW_HIDE
- else wShowWindow:= SW_SHOWNORMAL;
- end;
-
- Result := CreateProcess(nil,PChar(aCmdLine), nil, nil, False,
- NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);
- if aWait then
- if Result then
- begin
- WaitForInputIdle(ProcessInfo.hProcess, INFINITE);
- WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
- end;
- end;
-
-
- //---------------------- End of File....for now -----------------------------
- end.
-
-